package com.iwords.constants;


import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.math.BigDecimal;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.beanutils.BeanUtils;

/**
 * User: chonghuan Date: 2009-9-22 16:55:17
 */
public class QueryConstants {

	// 缓存cacheName
	public final static int CACHE_NAME_TAOCODE_GETMEMBERID = 50;
	public final static int CACHE_NAME_TAOCODE_GETPUBID = 51;//和后端失效保持一致
	public final static int CACHE_NAME_TAOCODE_TAOCODE2MINI = 52;//minisite 取淘代码cache name
	public final static String CACHE_KEY_TAOCODE_GETPUBID = "_CacheKey_processCodeList";//和后端失效保持一致
	
	public final static int CACHE_NAME_TAOCODE_GETRESOURCESINFO=53;
	public final static int CACHE_NAME_TAOCODE_GETTITLEBYUNIONID=54;
	//public final static String CACHE_KEY_TAOCODE_GETRESOURCESINFO="_getCacheKey_getResourcesInfo4Minisite";
	public final static int CODE_TAOCODE_PAYMENT_REUSE = 601;//结算返回重复调用
	public final static int CODE_TAOCODE_PAYMENT_CANCEL = 503;//结算返回取消

	// 编码表的module
	public final static String CODE_TAOCODE_CHECK_FAILCOUNT = "TAOCODE.CHECKFAILCOUNT";
	public final static String CODE_TAOCODE_ITEM_CAT = "ITEM_INFO.ITEMCATID"; // 宝贝类目
	public final static String CODE_TAOCODE_TYPE = "TAOCODE.TARGETTYPE"; // 淘代码类型
	public final static String CODE_TAOCODE_STATUS = "TAOCODE.STATUS"; // 淘代码状态，也叫在线状态
	public final static String CODE_TAOCODE_ILLEGAL_STATUS = "TAOCODE.ILLEGALSTATUS"; // 非法状态
	public final static String CODE_TAOCODE_URL_STATUS = "TAOCODE.URLSTATUS"; //
	public final static String CODE_TAOCODE_ITEM_STATUS = "ITEM_INFO.ITEMSTATUS"; //
	public final static String CODE_TAOCODE_URL_ITEM_STATUS = "ITEM_INFO.URLITEMSTATUS"; // 非法状态
	public final static String CODE_TAOCODE_PROMOTION_TYPE = "PUBLISHER.PROMOTION_TYPE";// 推广类型
	public final static String CODE_TAOCODE_SHOPSTATUS = "SHOP_INFO.SHOPSTATUS";// 店铺状态
	public final static String CODE_TAOCODE_PUBLISHER_TYPE = "PUBLISHER.PUB_TYPE";// 报刊类型
	public final static String CODE_TAOCODE_PUBLISHER_SCOPE = "PUBLISHER.PUB_SCOPE"; // 发行范围
	public final static String CODE_TAOCODE_REGISTER_ENTER_STATUS = "REGISTER.ENTER_STATUS"; // 候选状态
	public final static String CODE_TAOCODE_REGISTER_AD_STATUS = "REGISTER.AD_STATUS"; // 素材审批状态
	public final static String CODE_TAOCODE_REGISTER_AD_IMAGE_SIZE = "REGISTER_AD.IMAGE_SIZE"; // 用户上传图片素材大小

	public static String CODE_TAOCODE_PAYMENT_BCODE = ""; // 充值BCODE
	public static String CODE_TAOCODE_PAYMENT_INPUT_CHARSET = ""; // 充值字符编码
	public static String CODE_TAOCODE_PAYMENT_BPSIGNKEY = ""; // 充值签名
	public static String CODE_TAOCODE_PAYMENT_UURL = ""; // 充值签名

	// public final static String CODE_TAOCODE_PAYMENT_UURL=
	// "http://xentest5-vm17.corp.alimama.com:8080/alipayCharge.action?";
	// //充值签名(联调环境)

	public final static int CODE_TAOCODE_CHECK_FAILCOUNT_INIT = 0;
	public final static int CODE_TAOCODE_CHECK_FAILCOUNT_MAX = 99;

	public final static int CODE_TAOCODE_PAYMENTLOG_STATUS_UNDISPOSED = 0;//结算付款状态_未处理
	public final static int CODE_TAOCODE_PAYMENTLOG_STATUS_SUCCESS = 1;//结算付款状态_成功
	public final static int CODE_TAOCODE_PAYMENTLOG_STATUS_FAIL = 2;//结算付款状态_失败
	public final static int CODE_TAOCODE_PAYMENTLOG_STATUS_CANCEL = 3;//结算付款状态_取消

	// 导出淘代码信息file地址
	public static String TaoCodeDOExcelFile = "D:\\my.csv";

	// 全选状态值
	public final static int TAOCODE_SELECT_ALL_VALUE = -1;

	// 淘代码合法状态
	public final static int TAOCODE_LEGAL_LEGAL = 0;
	public final static int TAOCODE_LEGAL_SELF_ILLEGAL = 1;
	public final static int TAOCODE_LEGAL_ARTIFICIAL_ILLEGAL = 2;

	// 淘代码状态0：删除1：下线2：上线
	public final static int TC_TAOCODE_STATUS_REMOVED = 0;
	public final static int TC_TAOCODE_STATUS_OFFLINE = 1;
	public final static int TC_TAOCODE_STATUS_ONLINE = 2;

	// 目标类型:1:宝贝2:店铺9:其它
	public final static int TC_TAOCODE_TYPE_ITEM = 1;
	public final static int TC_TAOCODE_TYPE_SHOP = 2;
	public final static int TC_TAOCODE_TYPE_OTHERS = 9;

	// 淘代码推广方式
	public final static String PUBLISHER_PROMOTION_TYPE = "PUBLISHER.PROMOTION_TYPE";

	// 淘代码页面专题
	public final static String PAGE_TOPICS = "PAGE_TOPICS";
	// 淘代码店铺类目
	public final static String SHOP_INFO_CATEGORY = "SHOP_INFO.CATEGORY";

	// 宝贝警告信息
	public final static String ITEM_INFO_WARNINGINFO = "ITEM_INFO.WARNINGINFO";

	// 淘代码类型
	public static String TAOCODE_TARGETTYPE = "TAOCODE.TARGETTYPE";

	// 宝贝信息状态
	public final static int ITEM_STATUS_NORMAL1 = 0;
	public final static int ITEM_STATUS_NORMAL2 = 1;
	public final static int ITEM_STATUS_DEL_BY_CLIENT = -1;
	public final static int ITEM_STATUS_OFFLINE_BY_CLIENT = -2;
	public final static int ITEM_STATUS_OFFLINE_BY_XIAO2 = -3;
	public final static int ITEM_STATUS_DEL_BY_XIAO2 = -4;
	public final static int ITEM_STATUS_NEVER_ONLINE = -5;
	public final static int ITEM_STATUS_CC = -9;
	public final static int ITEM_STATUS_CHANGED = -10;
	public final static int ITEM_STATUS_ILLEGAL = -11;

	// 店铺状态
	/** 正常 */
	public final static int SHOP_STATUS_NORMAL = 0;
	/** 人为非法 */
	public final static int SHOP_STATUS_ILLEGAL = -11;

	// publishr状态
	public final static int PUBLISHER_STATUS_DEL = 0;
	public final static int PUBLISHER_STATUS_DOWNLINE = 1;
	public final static int PUBLISHER_STATUS_ONLINE = 2;

	// URL状态
	public final static int TAOCODE_URLSTATUS_INIT = 1;
	public final static int TAOCODE_URLSTATUS_NO_DEADLINK = 0;
	public final static int TAOCODE_URLSTATUS_DEADLINK = -20;
	public final static int TAOCODE_URLSTATUS_ILLEGAL = -11;

	// 淘代码状态
	public final static int TAOCODE_STATUS_DEL = 0;
	public final static int TAOCODE_STATUS_OFFLINE = 1;
	public final static int TAOCODE_STATUS_ONLINE = 2;

	// 淘代码目的类型
	public final static int TAOCODE_TYPE_ITEMID = 0;
	public final static int TAOCODE_TYPE_ITEM = 1;
	public final static int TAOCODE_TYPE_SHOP = 2;
	public final static int TAOCODE_TYPE_OTHER = 9;
	public final static int TAOCODE_TYPE_SHOP_ID = 4;

	// 检测URL超时时间
	public final static int CHECK_URL_CONNECT_TIME_OUT = 1000;
	public final static int CHECK_URL_READ_TIME_OUT = 3000;

	// 获取中心词超时时间
	public final static int GET_KEYWORD_TIME_OUT = 1000;
	// 获取中心词返回最大字节数
	public final static int GET_KEYWORD_MAX_BYPE = 32784;

	public static String WEB_RESOURCE_ROOT = "";

	public static String INTRANET_IP_REGEX = null;
	public static String DEPLOY_MODE = "dev";

	public static String SPM_SOCK = "";
	public static String SPM_GROUP = "";

	// 淘宝天下,mode,用于生成淘宝客点击串
	public static final String TAOCODE_MODE_ITEM = "91";

	// 淘宝天下,mode,用于生成淘宝客点击串
	public static final String TAOCODE_MODE_SHOP = "92";

	// 淘宝天下，type，用于生成淘宝客点击串，单品
	public static final String TAOCODE_CLICK_TYPE_SINGLE = "1";// 单品

	// 淘宝天下，type，用于生成淘宝客点击串，店铺
	public static final String TAOCODE_CLICK_TYPE_SHOP = "2";// 店铺

	// 淘宝登录页面
	public static String TAOBAO_LOGIN_URL = "";
	// 退出url
	public static String TAOBAO_LOGOUT_URL = "";
	// 帮助url
	public static String TAOCODE_HELP_URL = "";
	
	public final static String TC_TAOCODE_PUBLISHER_PUBTYPE_SELLPASS = "10";//媒体类型为卖家互递
	public final static String TC_TAOCODE_PUBLISHER_PUBTYPE_TAO10 = "b09";// 淘10惠
	public final static String TC_TAOCODE_PUBLISHER_PUBTYPE_TAOXY = "b01";// 淘校园

	public static String URLREGEX="taobao\\.com";//解析宝贝url
	
	public static final int  TC_TAOCODE_REGISTERAD_PROMOTIONTYPE_ITEM =1;//上传素材的推广类型
	public static final int  TC_TAOCODE_REGISTERAD_PROMOTIONTYPE_SHOP =2;//上传素材的推广类型
	
	public final static String CODE_TAOCODE_PUBLISHER_BROAD_HEADING = "PUBLISHER.BROAD_HEADING"; //媒体大类 渠道
	public final static String CODE_TAOCODE_PUBLISHER_BROAD_HEADING_M4 = "m4"; //媒体大类：团购 
	public final static String CODE_TAOCODE_PUBLISHER_BROAD_HEADING_M3 = "m3"; //媒体大类：DM 
	public final static String CODE_TAOCODE_PUBLISHER_BROAD_HEADING_M2 = "m2"; //媒体大类：报纸 
	public final static String CODE_TAOCODE_PUBLISHER_BROAD_HEADING_M1 = "m1"; //媒体大类：杂志 
	
	public final static Integer TC_TAOCODE_PERMITDISCOUNT1=1;//允许折扣
    public final static Integer TC_TAOCODE_PERMITDISCOUNT2=2;//禁止折扣
    
    public final static Integer TC_TAOCODE_DISCOUNTTYPE1=1;//折扣值
    public final static Integer TC_TAOCODE_DISCOUNTTYPE2=2;//折扣率
    
    public final static BigDecimal BIGDECIMAL_100 = new BigDecimal("100");
    public final static BigDecimal BIGDECIMAL_100000 = new BigDecimal("100000");
    
    public final static int TC_PUBLISHER_TYPE_NORMAL = 1;//普通媒体
    public final static int TC_PUBLISHER_TYPE_XT = 2;//卖家互递(享淘)
    public final static int TC__PUBLISHER_TYPE_T10H = 3;//淘实惠
    
    public final static String TC_PUBCODE_ITEM="B";//自助宝贝
    public final static String TC_PUBCODE_SHOP="D";//自助店铺
    public final static String TC_PUBCODE_XT="V";//享淘活动
    
    //团状态：-1:删除;0:未扣款;1:已扣款;2:扣款中;3:已印刷
    public final static int XT_GROUP_STATUS_DELETE=-1;//删除
    public final static int XT_GROUP_STATUS_NOCHARGE=0;//未扣款
    public final static int XT_GROUP_STATUS_CHARGE=1;//已扣款
    public final static int XT_GROUP_STATUS_CHARGEING=2;//扣款中
    public final static int XT_GROUP_STATUS_PRINT=3;//已印刷
    
    public final static long XT_USER_RATE=1001l;//3钻
    public final static String XT_USER_RATENAME="3钻";//3钻
    
    public final static int TC_TAOCODE_DISCOUNT=100;//折扣单元换算
    
    public final static int Default_ACTIVITY_ITEMTCNUM=15;//活动报名默认itemtcnum
    
	public void setINTRANET_IP_REGEX(String INTRANET_IP_REGEX) {
		QueryConstants.INTRANET_IP_REGEX = INTRANET_IP_REGEX;
	}

	public void setDEPLOY_MODE(String DEPLOY_MODE) {
		QueryConstants.DEPLOY_MODE = DEPLOY_MODE;
	}

	static {
		getPropertyValue("/constants.properties");// 从constans.properties读取value，
		// 将常量重新赋值
	}

	public static void getPropertyValue(String fileName) {
		try {
			Properties props = new Properties();
			InputStream is = QueryConstants.class.getResourceAsStream(fileName);
			Reader reader = new InputStreamReader(is, "UTF-8");
			props.load(reader);

			Map map = new HashMap();
			QueryConstants constants = new QueryConstants();
			Enumeration enums = props.propertyNames();
			while (enums.hasMoreElements()) {
				String key = (String) enums.nextElement();
				map.put(key, props.getProperty(key.toUpperCase()));
			}
			BeanUtils.copyProperties(constants, map);
			// TAOBAO_LOGIN_URL = (String)map.get("TAOBAO_LOGIN_URL");
			// TAOBAO_LOGOUT_URL = (String)map.get("TAOBAO_LOGOUT_URL");

			is.close();
			reader.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String getWEB_RESOURCE_ROOT() {
		return WEB_RESOURCE_ROOT;
	}

	public void setWEB_RESOURCE_ROOT(String web_resource_root) {
		WEB_RESOURCE_ROOT = web_resource_root;
	}

	public String getSPM_SOCK() {
		return SPM_SOCK;
	}

	public void setSPM_SOCK(String sPMSOCK) {
		QueryConstants.SPM_SOCK = sPMSOCK;
	}

	public String getSPM_GROUP() {
		return SPM_GROUP;
	}

	public void setSPM_GROUP(String sPMGROUP) {
		QueryConstants.SPM_GROUP = sPMGROUP;
	}

	public String getTAOBAO_LOGIN_URL() {
		return TAOBAO_LOGIN_URL;
	}

	public void setTAOBAO_LOGIN_URL(String tAOBAOLOGINURL) {
		TAOBAO_LOGIN_URL = tAOBAOLOGINURL;
	}

	public String getTAOBAO_LOGOUT_URL() {
		return TAOBAO_LOGOUT_URL;
	}

	public void setTAOBAO_LOGOUT_URL(String tAOBAOLOGOUTURL) {
		TAOBAO_LOGOUT_URL = tAOBAOLOGOUTURL;
	}

	public String getCODE_TAOCODE_PAYMENT_BCODE() {
		return CODE_TAOCODE_PAYMENT_BCODE;
	}

	public void setCODE_TAOCODE_PAYMENT_BCODE(String cODETAOCODEPAYMENTBCODE) {
		CODE_TAOCODE_PAYMENT_BCODE = cODETAOCODEPAYMENTBCODE;
	}

	public String getCODE_TAOCODE_PAYMENT_INPUT_CHARSET() {
		return CODE_TAOCODE_PAYMENT_INPUT_CHARSET;
	}

	public void setCODE_TAOCODE_PAYMENT_INPUT_CHARSET(
			String cODETAOCODEPAYMENTINPUTCHARSET) {
		CODE_TAOCODE_PAYMENT_INPUT_CHARSET = cODETAOCODEPAYMENTINPUTCHARSET;
	}

	public String getCODE_TAOCODE_PAYMENT_BPSIGNKEY() {
		return CODE_TAOCODE_PAYMENT_BPSIGNKEY;
	}

	public void setCODE_TAOCODE_PAYMENT_BPSIGNKEY(
			String cODETAOCODEPAYMENTBPSIGNKEY) {
		CODE_TAOCODE_PAYMENT_BPSIGNKEY = cODETAOCODEPAYMENTBPSIGNKEY;
	}

	public String getCODE_TAOCODE_PAYMENT_UURL() {
		return CODE_TAOCODE_PAYMENT_UURL;
	}

	public void setCODE_TAOCODE_PAYMENT_UURL(String cODETAOCODEPAYMENTUURL) {
		CODE_TAOCODE_PAYMENT_UURL = cODETAOCODEPAYMENTUURL;
	}

	public String getTAOCODE_HELP_URL() {
		return TAOCODE_HELP_URL;
	}

	public void setTAOCODE_HELP_URL(String tAOCODEHELPURL) {
		TAOCODE_HELP_URL = tAOCODEHELPURL;
	}

   public String getURLREGEX() {
    return URLREGEX;
   }

    public void setURLREGEX(String uRLREGEX) {
        URLREGEX = uRLREGEX;
    }

}